﻿
using System ;

using MskEdit.Sdk ;


namespace MskEdit.Dxf.Representation
{

    internal static class GroupCodeRanges
    {
        internal static SdkSubrange String2049A     = new SdkSubrange( 0,  10 ) ; // 9
        internal static SdkSubrange Double3DPoint   = new SdkSubrange( 10,  30 ) ; // 39 Double precision 3D point value
        internal static SdkSubrange DoubleFloatA    = new SdkSubrange( 40,  20 ) ; // 59 Double-precision floating-point value
        internal static SdkSubrange Integer16A      = new SdkSubrange( 60,  20 ) ; // 79 16-bit integer value
        internal static SdkSubrange Integer32A      = new SdkSubrange( 90,  10 ) ; // 99 32-bit integer value
        internal static SdkSubrange StringMax255A   = new SdkSubrange( 100,   1 ) ; // String ( 255-character maximum ; less for Unicode strings )
        internal static SdkSubrange StringMax255B   = new SdkSubrange( 102,   1 ) ; // String ( 255-character maximum ; less for Unicode strings )
        internal static SdkSubrange StringHandleA   = new SdkSubrange( 105,   1 ) ; // String representing hexadecimal ( hex ) handle value
        internal static SdkSubrange DoubleFloatB    = new SdkSubrange( 110,  10 ) ; // 119 Double precision floating-point value
        internal static SdkSubrange DoubleFloatC    = new SdkSubrange( 120,  10 ) ; // 129 Double precision floating-point value
        internal static SdkSubrange DoubleFloatD    = new SdkSubrange( 130,  10 ) ; // 139 Double precision floating-point value
        internal static SdkSubrange DoubleFloatE    = new SdkSubrange( 140,  10 ) ; // 149 Double precision scalar floating-point value
        internal static SdkSubrange Integer64       = new SdkSubrange( 160,  10 ) ; // 169 64-bit integer value
        internal static SdkSubrange Integer16B      = new SdkSubrange( 170,  10 ) ; // 179 16-bit integer value
        internal static SdkSubrange DoubleFloatF    = new SdkSubrange( 210,  20 ) ; // 239 Double-precision floating-point value
        internal static SdkSubrange Integer16C      = new SdkSubrange( 270,  10 ) ; // 279 16-bit integer value
        internal static SdkSubrange Integer16D      = new SdkSubrange( 280,  10 ) ; // 289 16-bit integer value
        internal static SdkSubrange BoolA           = new SdkSubrange( 290,  10 ) ; // 299 Boolean flag value
        internal static SdkSubrange StringArbitrary = new SdkSubrange( 300,  10 ) ; // 309 Arbitrary text string
        internal static SdkSubrange StringHexChunk  = new SdkSubrange( 310,  10 ) ; // 319 String representing hex value of binary chunk
        internal static SdkSubrange StringHandleB   = new SdkSubrange( 320,  10 ) ; // 329 String representing hex handle value
        internal static SdkSubrange StringHexObjId  = new SdkSubrange( 330,  40 ) ; // 369 String representing hex object IDs
        internal static SdkSubrange Integer16E      = new SdkSubrange( 370,  10 ) ; // 379 16-bit integer value
        internal static SdkSubrange Integer16F      = new SdkSubrange( 380,  10 ) ; // 389 16-bit integer value
        internal static SdkSubrange StringHandleC   = new SdkSubrange( 390,  10 ) ; // 399 String representing hex handle value
        internal static SdkSubrange Integer16G      = new SdkSubrange( 400,  10 ) ; // 409 16-bit integer value
        internal static SdkSubrange StringA         = new SdkSubrange( 410,  10 ) ; // 419 String
        internal static SdkSubrange Integer32B      = new SdkSubrange( 420,  10 ) ; // 429 32-bit integer value
        internal static SdkSubrange StringB         = new SdkSubrange( 430,  10 ) ; // 439 String
        internal static SdkSubrange Integer32C      = new SdkSubrange( 440,  10 ) ; // 449 32-bit integer value
        internal static SdkSubrange LongA           = new SdkSubrange( 450,  10 ) ; // 459 Long
        internal static SdkSubrange DoubleFloatG    = new SdkSubrange( 460,  10 ) ; // 469 Double-precision floating-point value
        internal static SdkSubrange StringC         = new SdkSubrange( 470,  10 ) ; // 479 String
        internal static SdkSubrange StringHandleD   = new SdkSubrange( 480,   2 ) ; // 481 String representing hex handle value
        internal static SdkSubrange StringComment   = new SdkSubrange( 999,   1 ) ; // Comment ( string )
        internal static SdkSubrange String2049B     = new SdkSubrange( 1000,  10 ) ; // 1009 String ( same limits as indicated with 0-9 code range )
        internal static SdkSubrange DoubleFloatH    = new SdkSubrange( 1010,  40 ) ; // 1059 Double-precision floating-point value
        internal static SdkSubrange Integer16H      = new SdkSubrange( 1060,  11 ) ; // 1070 16-bit integer value
        internal static SdkSubrange Integer32D      = new SdkSubrange( 1071,   1 ) ; // 32-bit integer value
        
        
        internal static bool IsValidCode( int code ) {
        
            if ( IsStringCode( code ) )
                return true ;
                
            if ( IsDouble3dPointCode( code ) )
                return true ;
                
            if ( IsDoubleCode( code ) )
                return true ;
                
            if ( IsShortCode( code ) )
                return true ;
                
            if ( IsIntCode( code ) )
                return true ;
                
            if ( IsBoolCode( code ) )
                return true ;
                
            if ( IsLongCode( code ) )
                return true ;
                
            return false ;
        }
        
        
        internal static bool IsBoolCode( int code ) {
            
            if ( BoolA.Contains( code ) )
                return true ;
                  
            return false ;
        }
        
        
        internal static bool IsShortCode( int code ) {
            
            if ( Integer16A.Contains( code ) )
                return true ;
            
            if ( Integer16B.Contains( code ) )
                return true ;
            
            if ( Integer16C.Contains( code ) )
                return true ;
            
            if ( Integer16D.Contains( code ) )
                return true ;
            
            if ( Integer16E.Contains( code ) )
                return true ;
            
            if ( Integer16F.Contains( code ) )
                return true ;
            
            if ( Integer16G.Contains( code ) )
                return true ;
            
            if ( Integer16H.Contains( code ) )
                return true ;
                  
            return false ;
        }
        
        
        internal static bool IsIntCode( int code ) {
            
            if ( Integer32A.Contains( code ) )
                return true ;
            
            if ( Integer32B.Contains( code ) )
                return true ;
            
            if ( Integer32C.Contains( code ) )
                return true ;
            
            if ( Integer32D.Contains( code ) )
                return true ;
                  
            return false ;
        }
                
            
        internal static bool IsLongCode( int code ) {
            
            if ( LongA.Contains( code ) )
                return true ;
                  
            return false ;
        }
      
        
        internal static bool IsDoubleCode( int code ) {
            
            if ( DoubleFloatA.Contains( code ) )
                return true ;
            
            if ( DoubleFloatB.Contains( code ) )
                return true ;
            
            if ( DoubleFloatC.Contains( code ) )
                return true ;
            
            if ( DoubleFloatD.Contains( code ) )
                return true ;
            
            if ( DoubleFloatE.Contains( code ) )
                return true ;
            
            if ( DoubleFloatF.Contains( code ) )
                return true ;
            
            if ( DoubleFloatG.Contains( code ) )
                return true ;
            
            if ( DoubleFloatH.Contains( code ) )
                return true ;
                
            return false ;
        }
        
        
        internal static bool IsDouble3dPointCode( int code ) {
            
            if ( Double3DPoint.Contains( code ) )
                return true ;
                
            return false ;
        }
        
        
        internal static bool IsStringCode( int code ) {
            
            if ( String2049A.Contains( code ) )
                return true ;
                
            if ( StringMax255A.Contains( code ) )
                return true ;
                
            if ( StringMax255B.Contains( code ) )
                return true ;
                
            if ( StringHandleA.Contains( code ) )
                return true ;
                
            if ( StringArbitrary.Contains( code ) )
                return true ;
                
            if ( StringHexChunk.Contains( code ) )
                return true ;
                
            if ( StringHandleB.Contains( code ) )
                return true ;
                
            if ( StringHexObjId.Contains( code ) )
                return true ;
                
            if ( StringHandleC.Contains( code ) )
                return true ;
                
            if ( StringA.Contains( code ) )
                return true ;
                
            if ( StringB.Contains( code ) )
                return true ;
                
            if ( StringC.Contains( code ) )
                return true ;
                
            if ( StringHandleD.Contains( code ) )
                return true ;
                
            if ( StringComment.Contains( code ) )
                return true ;
                
            if ( String2049B.Contains( code ) )
                return true ;
                
            return false ;
        }
    }
}
